﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using STLGROUP.Layers.Presentations;
using STLGROUP.Layers.ReportTemplates;
using STLGROUP.Layers.Common;

namespace QuanLyBanHang
{
    public partial class RF004 : frmReportBase
    {
        private int _iDDonHang;

        public int IDDonHang
        {
            get { return _iDDonHang; }
            set { _iDDonHang = value; }
        }

        public RF004()
        {
            InitializeComponent();
            this.Load += new EventHandler(RF004_Load);
        }

        private void RF004_Load(object sender, EventArgs e)
        {
            try
            {
                CR004_DonDatHangNCC rp = new CR004_DonDatHangNCC();
                
                var data = Cache.Context.View_DatHangNhaCungCap.Where(s => s.IDDonDatHang == IDDonHang).Select(s => new
                {
                    s.MaDonDatHang,
                    s.MaNhanVien,
                    s.HoTenNhanVien,
                    s.SDTNhanVien,
                    s.DiaChiNV,
                    s.MaNhaCungCap,
                    s.TenNhaCungCap,
                    s.SoDienThoai,
                    s.DiaChi,
                    s.MaSanPham,
                    s.TenSanPham,
                    s.SoLuongDat,
                    s.GiaNhap,
                    s.ThanhTien,
                    s.DonViTienTe,
                    s.DaThanhToan,
                    s.ConLai
                });
                rp.SetDataSource(data);

                crystalReportViewer.ReportSource = rp;

            }
            catch (Exception ex)
            {
                UICommon.ShowMessgeString("Xảy ra lỗi trong quá trình xuất đơn đặt hàng "+ex.Message, "Lỗi xuất report");
            }
        }
    }
}
